package com.hilinos.ftp.api;

import com.hilinos.ftp.anno.Auth;
import com.hilinos.ftp.pojo.ConfigPojo;
import com.hilinos.ftp.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("config")
public class ConfigApi {

    @Autowired
    private ConfigService configService;

    @Auth("admin")
    @PostMapping("edit")
    public void edit(@RequestBody List<ConfigPojo> configs) {
        if (ObjectUtils.isEmpty(configs)) {
            return;
        }
        configService.edit(configs);
    }

    /**
     * 获取所有用户配置
     *
     * @return
     */
    @GetMapping("userConfig")
    public List<ConfigPojo> getAllUserConfig() {
        return configService.getAllUserConfig();
    }
}
